<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>BSS Camera</title>
</head>
<body>
	<table><tr><td valign=top>
	<h1>BSS Patient Photograph</h1>
		
	<!-- First, include the JPEGCam JavaScript Library -->
	<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/webcam/webcam.js"></script>
	
	<!-- Configure a few settings -->
	<script language="JavaScript">
		//alert('${request.contextPath}');
		webcam.set_api_url( '<%=request.getContextPath()%>/bss/images/click' );
		webcam.set_quality( 100 ); // JPEG quality (1 - 100)
		//webcam.set_shutter_sound( true ); // play shutter click sound
	</script>
	
	<!-- Next, write the movie to the page at 320x240 -->
	<script language="JavaScript">
		document.write( webcam.get_html(320, 240) );
	</script>
	
	<!-- Some buttons for controlling things -->
	<br/>
	<form>
		<input type=button value="Click" onClick="take_snapshot()">
	</form>
	
	<!-- Code to handle the server response (see test.php) -->
	<script language="JavaScript">
		webcam.set_hook( 'onComplete', 'my_completion_handler' );		
		
		function take_snapshot() {
			// take snapshot and upload to server
			document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>';
			webcam.snap();
		}
		
		
		function my_completion_handler(msg) {
			//alert('Output: '+msg);
			clicked(msg);
		}

		function clicked(im) {

			try {
				window.dialogArguments.setImage(im);
			}catch(e) {
				//alert('Error while trying setImage() '+e);
				try {
					window.opener.doSubmit(im);
				}catch(e) {
					alert('Error while trying doSubmit() '+e);
				}
			}
			window.close();
		}
	</script>
	
	</td>	
	<td valign=top>
		<div id="upload_results" style="background-color:#eee;"></div>
	</td></tr></table>
</body>
</html>
